<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
	</head>
	<style type="text/css">
		* {
			margin: 0;
			padding: 0;
			background: #f9f9f9;
		}
		
		input {
			-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
			-webkit-user-select: none;
			-moz-user-focus: none;
			-moz-user-select: none;
			-webkit-appearance: none;
			outline: none;
			border: none;
		}
		
		.sj {
			width: 240px;
		}
		
		header {
			width: 200px;
			text-align: center;
			margin: 0 auto;
			margin-top: 10%;
		}
		
		.cont {
			width: 300px;
			margin: 0 auto;
			text-align: center;
			margin-top: 20%;
		}
		
		.cont input {
			border: 1px solid dodgerblue;
			height: 40px;
			border-radius: 10px;
		}
		
		.yz {
			width: 140px;
			border: 0 !important;
		}
		
		#btn {
			width: 100px;
			height: 42px;
			border: 0;
		}
		
		.yzm {
			width: 240px;
			margin: 0 auto;
			border-radius: 10px;
			border: 1px solid dodgerblue;
			margin-top: 10px;
		}
		
		.go {
			width: 240px;
			text-align: center;
			height: 40px !important;
			border-radius: 10px;
			line-height: 40px;
			color: white;
			background: dodgerblue;
			margin: 0 auto;
			margin-top: 50px;
		}
	</style>

	<body>
		<header><img src="img/logo.png" /></header>
		<div class="cont">
			<input type="text" class="sj" name="" id="ssoid" value="" onblur="upperCase()" placeholder="手机号码" /><br>
			<div class="yzm"><input type="text" class="yz" name="" id="" value="" /><input type="button" id="btn" value="获取验证码" onclick="sendemail()"></input>
			</div>

		</div>
		<div class="go">立即注册</div>
	</body>
	<script src="dist/js/jquery-3.1.1.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="dist/js/util.js" type="text/javascript" charset="utf-8"></script>
	<script src="../static/js/ip.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		var Inbox = getParam("inbox", "")
		var countdown = 60;
		//验证手机号
		function upperCase()

		{

			var phone = document.getElementById('ssoid').value;

			if(!(/^1[34578]\d{9}$/.test(phone))) {
				$('#ssoid').val('')
				$('#ssoid').attr('placeholder', '手机号码有误！')

				return false;

			}

		}

		function sendemail() {
			var obj = $("#btn");

			$.ajax({
				type: "post",
				url: 'http://haiban.kepiture.com/haiban-api/generalize/sendcaptcha',
				data: {
					phone: $("#ssoid").val(),
					phoneCode: '86'
				},
				success: function(data) {
					if(data.msg == '用户已注册') {
						$('#ssoid').val('')
						$('#ssoid').attr('placeholder', '用户以注册！')
						return
					}

					settime(obj);
				},
				error: function() {
					console.log("shibai")
				}
			});

		}
		$('.go').click(function() {
			$.ajax({
				type: "post",
				url: 'http://haiban.kepiture.com/haiban-api/generalize/register',
				data: {
					phone: $("#ssoid").val(),
					phoneCode: '86',
					captcha: $(".yz").val(),
					inviterSharecode: Inbox
				},
				success: function(data) {
					console.log(data)
					if(data.code == 1) {
						$(".yz").val('')
						$(".yz").attr('placeholder', '验证码错误')
					}
					if(data.code == 0) {
						window.location.href = 'https://haiban.haiqitech.cn/haiban-api/'

					}

				},
				error: function() {
					console.log("shibai")
				}
			});
		})

		function settime(obj) { //发送验证码倒计时
			if(countdown == 0) {
				obj.attr('disabled', false);
				//obj.removeattr("disabled"); 
				obj.val("重新发送");
				countdown = 60;
				return;
			} else {
				obj.attr('disabled', true);
				obj.val("(" + countdown + ")重新发送");
				countdown--;
			}
			setTimeout(function() {
				settime(obj)
			}, 1000)
		}
	</script>

</html>